DAY14:Quarter of the year


Posted by birdbirdmurmur on 2023-07-27

題目

Quarter of the year

解法:

第一版

const quarterOf = (month) => {
  if (month >= 1 && month <= 3) {
    return 1;
  } else if (month >= 4 && month <= 6) {
    return 2;
  } else if (month >= 7 && month <= 9) {
    return 3;
  } else {
    return 4;
  }
}

第二版:Math.ceil

const quarterOf = (month) => {
  return Math.ceil(month / 3);
}

筆記

第一版很簡單地解開
第二版想用Math語法,但忘了要用哪個
翻了一下MDN使用Math.ceil做無條件進位


#javascript #Codewars #Math.ceil







Related Posts

滲透測試重新打底(3.6)--論Web入侵之SSRF攻擊

滲透測試重新打底(3.6)--論Web入侵之SSRF攻擊

〈 Diffusion Model 論文研究與實作心得 Part.1 〉 前言與圖片雜訊前處理

〈 Diffusion Model 論文研究與實作心得 Part.1 〉 前言與圖片雜訊前處理

[C#] 如何透過 EmailMessage 寄代理傳送者郵件 How to send an email on half of another user via EmailMessage

[C#] 如何透過 EmailMessage 寄代理傳送者郵件 How to send an email on half of another user via EmailMessage


Comments